#pragma once
#ifndef __TIMER_H__
#define __TIMER_H__

#include "Utility.h"

#include "../util/PreDeclare.h"
#include "../util/D3DCommon.h"

namespace WindGE
{
	class WIND_CORE_API Timer
	{
	private:
		Timer();
		Timer(const Timer&);
		Timer & operator = (const Timer&);

	public:
		static Timer & Instance()
		{
			static Timer inst;
			return inst;
		}

	public:
		inline float total_time() const {
			return (float)((((is_stopped_ ? stop_time_ : cur_time_) - pause_time_) - base_time_) * second_per_count_);
		}

		inline float delta_time() const { return (float)delta_time_; }

		void reset();
		void start();
		void stop();
		void tick();

	private:
		double second_per_count_;
		double delta_time_;
		
		__int64	base_time_;
		__int64	pause_time_;
		__int64	stop_time_;
		__int64	prev_time_;
		__int64	cur_time_;

		bool is_stopped_;
	};

}//end namespace WindGE

#endif // !__TIMER_H__



